#include"outputelementstream.h"
#include<errno.h>
#include<fcntl.h>
#include<iostream>
#include<cstring>

void outputelementstream::create(const char* fileName)
{
	this->fd = open(fileName, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
	if(this->fd == -1)
		std::cout << "Error opening stream: " << strerror( errno ) << std::endl;
}

void outputelementstream::close_s()
{
	int ret = close(this->fd);
	if(ret < 0)
		std::cout << "Error closing stream: " << strerror( errno ) << std::endl;
}

void outputelementstream::write_s(int data)
{
	if(write(this->fd, &data, sizeof(int)) < 0)
		std::cout << "Error writing to stream: " << strerror( errno ) << std::endl;
}
